package com.ruoyi.framework.mybatisplus.handle;

import com.ruoyi.common.utils.DateUtils;
import net.sf.jsqlparser.expression.Expression;
import net.sf.jsqlparser.expression.StringValue;
import net.sf.jsqlparser.statement.Statement;
import net.sf.jsqlparser.statement.insert.Insert;
import net.sf.jsqlparser.statement.update.Update;
import org.springframework.stereotype.Component;

/**
 * @author yql
 * @describe GenerateUuidHandler
 * @date 2023/3/13 17:07
 */
@Component
public class UpdateTimeGenerateHandler implements GenerateHandler {

    @Override
    public Expression getValue() {
        return new StringValue(DateUtils.getTime());
    }

    @Override
    public String getFieldName() {
        return "update_time";
    }

    @Override
    public boolean off(Statement statement) {
        return statement instanceof Update || statement instanceof Insert;
    }
}
